#include<iostream>
#include<map>
using namespace std;

bool canConstructSelf(string ransomNote, string magazine) 
{
    unordered_map<char,int> magsum;
    for(auto magchar:magazine)
    {
        ++magsum[magchar];
    }
    for(auto ransomchar:ransomNote)
    {
        if(magsum.count(ransomchar))
        {
            magsum[ransomchar]--;
            if(magsum[ransomchar]<0)
                return false;
        }
        else
            return false;
    }
    return true;
}

bool canConstruct(string ransomNote, string magazine) {
    unordered_map<char, int> counts;
    for (char c : magazine) {
        counts[c]++;
    }
    for (char c : ransomNote) {
        if (counts[c] > 0) {
            counts[c]--;
        } else {
            return false;
        }
    }
    return true;
}

int main()
{
    string a="aa";
    string b="aab";
    cout<<canConstruct(a,b);
}